package com.fh.service.attachment;

import com.fh.dao.DaoSupport;
import com.fh.entity.Page;
import com.fh.util.PageData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by lr on 2017/10/17.
 */
@Service("attachmentService")
public class AttachmentService {
    @Resource(name = "daoSupport")
    private DaoSupport dao;

    /*
    * 新增附件
    */
    public void saveAttachment(PageData pd) throws Exception {
        dao.save("AttachmentMapper.saveAttachment", pd);
    }

    /*
    * 删除附件根据OID
    */
    public void deleteAttachmentByOid(PageData pd) throws Exception {
        dao.update("AttachmentMapper.deleteAttachmentByOid", pd);
    }

    /*
    * 删除附件根据OID(真实删除)
    */
    public void realDeleteAttachmentByOid(PageData pd) throws Exception {
        dao.delete("AttachmentMapper.realDeleteAttachmentByOid", pd);
    }

    /*
     * 删除附件根据ID(真实删除)
     */
    public void realDeleteAttachmentByid(PageData pd) throws Exception {
        dao.delete("AttachmentMapper.realDeleteAttachmentByid", pd);
    }

    /*
    * 查询关联ID下的附件
    */
    public List<PageData> findByOId(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("AttachmentMapper.findByOId", pd);
    }

}
